//
//  LoveCarAgeCell.m
//  New_Runway
//
//  Created by mack on 2018/2/11.
//  Copyright © 2018年 NelsonJ. All rights reserved.
//

#import "LoveCarAgeCell.h"

@interface LoveCarAgeCell ()
@property (nonatomic, strong)  PYEchartsView *kEchartView;

@end

@implementation LoveCarAgeCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self addAllViews];
        self.contentView.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

-(void)addAllViews{
    
    _kEchartView = [[PYEchartsView alloc] init];
    [self addSubview:_kEchartView];
    kSelfWeak;
    [_kEchartView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.bottom.equalTo(weakSelf);
    }];
    
    
    
    
}

-(PYOption *)standardPieOption{
    return [PYOption initPYOptionWithBlock:^(PYOption *option) {
        option.titleEqual([PYTitle initPYTitleWithBlock:^(PYTitle *title) {
            title.textEqual(@"")
            .subtextEqual(@"")
            .xEqual(PYPositionCenter);
        }])
        .tooltipEqual([PYTooltip initPYTooltipWithBlock:^(PYTooltip *tooltip) {
            tooltip.triggerEqual(PYTooltipTriggerItem)
            .formatterEqual(@"{a} <br/>{b} : {c} ({d}%)");
        }])
        .legendEqual([PYLegend initPYLegendWithBlock:^(PYLegend *legend) {
            legend.orientEqual(PYOrientVertical)
            .xEqual(PYPositionLeft)
            .dataEqual(_ageNames);
        }])
        .toolboxEqual([PYToolbox initPYToolboxWithBlock:^(PYToolbox *toolbox) {
            toolbox.showEqual(NO)
            .featureEqual([PYToolboxFeature initPYToolboxFeatureWithBlock:^(PYToolboxFeature *feature) {
                feature.markEqual([PYToolboxFeatureMark initPYToolboxFeatureMarkWithBlock:^(PYToolboxFeatureMark *mark) {
                    mark.showEqual(YES);
                }])
                .dataViewEqual([PYToolboxFeatureDataView initPYToolboxFeatureDataViewWithBlock:^(PYToolboxFeatureDataView *dataView) {
                    dataView.showEqual(YES).readOnlyEqual(NO);
                }])
                .magicTypeEqual([PYToolboxFeatureMagicType initPYToolboxFeatureMagicTypeWithBlock:^(PYToolboxFeatureMagicType *magicType) {
                    magicType.showEqual(YES).typeEqual(@[PYSeriesTypePie, PYSeriesTypeFunnel]).optionEqual(@{@"funnel":@{@"x":@"25%",@"width":@"50%",@"funnelAlign":PYPositionLeft,@"max":@(self.ageTotal)}});
                    
                }])
                .restoreEqual([PYToolboxFeatureRestore initPYToolboxFeatureRestoreWithBlock:^(PYToolboxFeatureRestore *restore) {
                    restore.showEqual(YES);
                }]);
            }]);
        }])
        .addSeries([PYPieSeries initPYPieSeriesWithBlock:^(PYPieSeries *series) {
            series.radiusEqual(@"45%")
            .centerEqual(@[@"50%",@"60%"])
            .nameEqual(@"偏爱车辆车辆价格")
            .typeEqual(PYSeriesTypePie)
            .dataEqual(_ListArray);
        }]);
    }];
}

-(void)setListArray:(NSMutableArray *)ListArray{
    _ListArray = ListArray;
    
    PYOption *option = [self standardPieOption];
    [_kEchartView setOption:option];
    [_kEchartView loadEcharts];
}

-(void)setAgeNames:(NSMutableArray *)ageNames{
    _ageNames = ageNames;
}
-(void)setAgeTotal:(CGFloat)ageTotal{
    
    _ageTotal = ageTotal;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
